/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Algorithm;

import java.util.Map;
import java.util.HashMap;

/**
 *使用了α-β剪枝和置换表改善搜索速度，置换表在Position类中定义
 * @author ErikLee
 */

public class Position {

    private int[][] board;

    public Position(int[][] theBoard) {
        board = new int[3][3];
        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++)
                board[i][j] = theBoard[i][j];
    }

    public boolean equals(Object rhs) {
        if (!(rhs instanceof Position)) {
            return false;
        }

        Position other = (Position) rhs;

        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++)
                if (board[i][j] != ((Position) rhs).board[i][j]) {
                    return false;
                }
        return true;
    }

    public int hashCode() {
        int hashVal = 0;

        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++)
                hashVal = hashVal * 4 + board[i][j];
        return hashVal;
    }
}